//
//  SaveSuccessPreViewController.m
//  BigJoy
//
//  Created by Rowling on 2017/7/19.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "SaveSuccessPreViewController.h"
#import "SDCycleScrollView.h"
#import "BuyView.h"
#import "SaleViewController.h"

@interface SaveSuccessPreViewController ()
@property (weak, nonatomic) IBOutlet UIView *contentView;
@property (nonatomic,strong) SDCycleScrollView *cycleView;

@end

@implementation SaveSuccessPreViewController

-(SDCycleScrollView *)cycleView {
    if(_cycleView == nil) {
        _cycleView = [[SDCycleScrollView alloc]init];
        _cycleView.autoScrollTimeInterval = 4;
        _cycleView.backgroundColor     = [UIColor whiteColor];
        _cycleView.pageDotColor = [UIColor clearColor];
        _cycleView.currentPageDotColor = [UIColor whiteColor];
        _cycleView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
    }
    return  _cycleView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.contentView addSubview: self.cycleView];
    self.title = @"预览";
    [self.cycleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.top.equalTo(self.contentView);
    }];
    self.cycleView.localizationImageNamesGroup = self.imgArray;
    self.navigationItem.leftBarButtonItem = [self itemWithimage:[UIImage imageNamed:@"refresh_arrow"] selImage:[UIImage imageNamed:@"refresh_arrow"] target:self action:@selector(goback)];
}

// 快速创建barButtonItem
- (UIBarButtonItem *)itemWithimage:(UIImage *)image selImage:(UIImage *)selImage target:(id)target action:(SEL)action
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:image forState:UIControlStateNormal];
    //[btn setImage:selImage forState:UIControlStateSelected];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}

-(void)goback {
    [self.navigationController popToViewController:self.navigationController.childViewControllers[1] animated:YES];
}
// 购买
- (IBAction)buyButtonClick:(id)sender {
    BuyView * buyView = [[BuyView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [buyView animationShowWithView:XMKEYWINDOWXM];
}
// 出售
- (IBAction)saleButtonClick:(id)sender {
    SaleViewController * vc = [SaleViewController new];
    vc.imgArray = self.imgArray;
    [self.navigationController pushViewController:vc animated:YES];
}

@end
